package com.linlong.linlongchat.handler;

import com.alibaba.fastjson.JSON;
import com.linlong.linlongchat.IMService;
import com.linlong.linlongchat.domain.websocket.data.Command;
import io.netty.channel.Channel;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.http.websocketx.TextWebSocketFrame;

public class ApplyResponseHandler {
    public static void execute(ChannelHandlerContext ctx, TextWebSocketFrame frame) {
        Command command = JSON.parseObject(frame.text(), Command.class);
        Channel channel = IMService.USERS.get(command.getTargetId());
        channel.writeAndFlush(new TextWebSocketFrame(JSON.toJSONString(command)));
    }
}
